package com.project.collectAPI.controller;

import com.project.collectAPI.comm.Constant;
import com.project.collectAPI.comm.SpiderTools;
import com.project.collectAPI.entity.Savedata;
import com.project.collectAPI.service.SavedataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.List;

@Controller
@Slf4j
@RequestMapping("data/")
public class dataController {

    @Resource
    private SavedataService savedataService;

    //ajax主机IP地址
    public static final String ServerIP= Constant.ServerIP;

    @GetMapping(value = {"/","/dataIndex"})
    public String index(Model model, HttpServletRequest request) throws IOException {
        int[] numArr=new int[10];
        for (int i = 0; i < 10; i++) {
            numArr[i]=i;
        }

        List<Savedata> getProductsDatas=savedataService.getProductsDatas(SpiderTools.StoreName);

        model.addAttribute("getProductsDatas",getProductsDatas);
        model.addAttribute("numArr",numArr);

        return "dataIndex";
    }



}
